package com.luminous.aether.kits;

/**
 * 类型转换工具类
 *
 * @author Luminous.X
 * @since 0.0.1-SNAPSHOT
 */
@SuppressWarnings("unused")
public class ConvertUtil {
    /**
     * 转换为字符串，无默认值
     *
     * @return 目标字符串
     */
    public static String toString(Object origin) {
        return toString(origin, null);
    }

    /**
     * 转换为字符串，指定默认值
     *
     * @return 目标字符串
     */
    public static String toString(Object origin, String defaultValue) {
        if (origin == null) {
            return defaultValue;
        }
        if (origin instanceof String target) {
            return target;
        }
        return origin.toString();
    }
}
